package com.ehome.poct.terminal.controller;

import com.ehome.poct.core.api.dto.check.OnlineCheckReqDTO;
import com.ehome.poct.core.api.vo.online.TodoOrderVO;
import com.ehome.poct.terminal.service.OnlineCheckService;
import com.ehome.web.annotation.RequestLog;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 患者
 *
 * @author cq
 * @since 2022/03/03 17:20
 **/
@Api(tags = "联机检测（和其他设备联机）")
@ApiSupport(author = "cq")
@RequestMapping("/online")
@RestController
@AllArgsConstructor
public class OnlineController {
    @Autowired
    OnlineCheckService checkServ;

    @ApiOperation("发起联机检测")
    @ApiOperationSupport(author = "cq")
    @PostMapping("/startOnline")
    @RequestLog
    public TodoOrderVO pub(@RequestBody OnlineCheckReqDTO onlineDTO) {
        return checkServ.startOnline(onlineDTO);
    }

    @ApiOperation("查询待检测列表")
    @ApiOperationSupport(author = "cq")
    @GetMapping("/todo/{clinicId}")
    @RequestLog
    public List<TodoOrderVO> getTodoList(@PathVariable @ApiParam("诊所ID") Long clinicId) {
        return checkServ.getTodoList(clinicId);
    }

    @ApiOperation("删除待检测")
    @ApiOperationSupport(author = "cq")
    @DeleteMapping("/del/record/{recordId}")
    @RequestLog
    public Boolean delUniRecord(@PathVariable @ApiParam("待检测记录ID") Long recordId) {
        return checkServ.delTodoOrder(recordId);
    }

    @ApiOperation("查询待检测订单状态")
    @ApiOperationSupport(author = "cq")
    @GetMapping("/todo/isExist/{recordId}")
    public Boolean todoIsExist(@PathVariable @ApiParam("待检测记录ID") Long recordId) {
        return checkServ.todoIsExist(recordId);
    }

    @ApiOperation("修改联测记录状态")
    @ApiOperationSupport(author = "cq")
    @PutMapping("/edit/record/{recordId}")
    @RequestLog
    public Boolean editUniRecord(@PathVariable Long recordId) {
        return checkServ.editUniRecord(recordId);
    }
}
